// import requireConfig from "@/plugin/requireConfig.js";
export default function requireShare(that, title, desc, cur_href, img_url) {

    var u = navigator.userAgent;
    // if (u.indexOf('Android') > -1) {
    //     requireConfig();
    // }
    if (22 > -1) {
        console.log('>')
        // console.log(encodeURI(window.location.href))
        var data = {
            auth_url: encodeURI(window.location.href),

        }
        that.$http
            .get("/getJsConfig",
                {
                    params: {
                        url: 'http://perrotin.com.cn' + cur_href,
                    }
                }
            )
            .then(res => {
                console.log(res.data)
                wx.config({
                    debug: false,
                    appId: res.data.appId,
                    timestamp: parseInt(res.data.timestamp),
                    nonceStr: res.data.nonceStr,
                    signature: res.data.signature,
                    jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"]
                })
            })
            .catch(error => {
                // console.log("6666")
                console.log(error)

            })

        // "/" + getJsConfig.WeChatAuthorzation(data)
        //     .then(res => {
        //         console.log('0000');
        //         console.log(res.data);
        //         if (code == 0) {
        //             wx.config({
        //                 debug: false,
        //                 appId: res.data.appId,
        //                 timestamp: parseInt(res.data.timestamp),
        //                 nonceStr: res.data.nonceStr,
        //                 signature: res.data.signature,
        //                 jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"]
        //             })
        //         }

        //     })
        //     .catch(error => {
        //         console.log(error)
        //     })

    }
    wx.ready(function () {
        console.log('9999000001222');
        wx.onMenuShareTimeline({

            title: title,
            desc: desc,
            link: 'http://perrotin.com.cn' + cur_href,
            imgUrl: img_url,
            success: function () {
                // ShareSuccess();
                console.log('成功')
                window.location.href = cur_href;
            },
            cancel: function () {
                console.log('取消')
                window.location.href = cur_href;
            }
        })
        wx.onMenuShareAppMessage({

            title: title,
            desc: desc,
            link: 'http://perrotin.com.cn' + cur_href,
            imgUrl: img_url,
            success: function () {
                // ShareSuccess();
                console.log('成功')
            },
            cancel: function () {
                console.log('取消')
            }
        })
        wx.checkJsApi({

            title: title,
            desc: desc,
            link: 'http://perrotin.com.cn' + cur_href,
            imgUrl: img_url,
            success: function () {
                // ShareSuccess();
                console.log('成功')
            },
            cancel: function () {
                console.log('取消')
            }
        })
    })
    wx.error(function (res) {
        console.log('err', res)
    });
}